import configparser
import pandas as pd

# 解析配置文件
config = configparser.ConfigParser()
config.read('Data_Control.ini')

# 读取excel文件
excel_file = 'case_data.xlsx'
df = pd.ExcelFile(excel_file)

# 根据配置决定是否处理全部单元格、‌部分表数据或部分单元格数据
if config['ExcelProcessing'].getboolean('process_all_cells'):
    #处理全部单元格
    df = pd.read_excel(excel_file)
    print("Processing all cells..")
elif config['ExcelProcessing'].getboolean('process_specific_sheet'):
    #处理特定表数据
    sheet_name = config['ExcelProcessing']['sheet_name']
    df = pd.read_excel(excel_file,sheet_name=sheet_name)
    print(f"Processing specific sheet：{sheet_name}")
elif config['ExcelProcessing'].getboolean('process_specific_cells'):
    #处理特定单元格数据
    sheet_name = config['ExcelProcessing']['sheet_name']
    df = pd.read_excel(excel_file,sheet_name=sheet_name)
    start_row = config['ExcelProcessing'].getint('start_row')
    start_col = config['ExcelProcessing'].getint('start_col')
    end_row = config['ExcelProcessing'].getint('end_row')
    end_col = config['ExcelProcessing'].getint('end_col')
    # 注意iloc是基于0的索引
    df = df.iloc[start_row-1:end_row,start_col-1:end_col]
    print(f"Processing specific cells from {sheet_name}:Rows{start_row}to")


